package com.feizi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.feizi.entity.UserEntity;
import com.feizi.service.RegisterService;

@Controller
public class RegisterController {
	@Autowired
	private RegisterService registerService;
	
	@RequestMapping(path="/register.do",method=RequestMethod.GET)
	public String register(UserEntity userEntity,Model model) {
		String pows=userEntity.getPasswords();
		String pow=userEntity.getPassword();
		if(pows==pow||pows.equals(pow)) {
			int rows=registerService.register(userEntity);
			if(rows>0) {
				return "login";
			}else {
				model.addAttribute("msg","注册失败，请核对信息");
				return "zhuce";
			}
		}else {
			model.addAttribute("msg","密码错误，请核对信息");
			return "zhuce";
		}
		
	}
}
